<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<a href="javascript:;" id="J_light">点我打开新窗口</a>
		<a href="javascript:;" id="J_lightIn">点我在页面上打开</a>
		<div id="J_lightDemoWrap" style="width: 700px;height: 500px;right:0;bottom:0;"></div>
		<!--[if lt IE 9]>
<script src="//g.alicdn.com/aliww/ww/json/json.js"></script>
<![endif]
<script src="https://g.alicdn.com/aliww/??h5.openim.sdk/0.1.4/scripts/wsdk.js,h5.openim.kit/0.0.5/scripts/kit.js" charset="utf-8"></script>     -->

		<script src="https://g.alicdn.com/aliww/??h5.openim.sdk/1.0.6/scripts/wsdk.js,h5.openim.kit/0.3.3/scripts/kit.js" charset="utf-8"></script>

		<script src="https://g.alicdn.com/aliww/h5.openim.sdk/1.0.6/scripts/wsdk.js"></script>
		<script type="text/javascript" src="jquery.min.js"></script>

		<script>
			document.getElementById('J_light').onclick = function() {
				window.open('http://www.taobao.com/market/seller/openim/kit.php?uid=test0&to=test1&appkey=23018936&pwd=123456&fullscreen', 'webcall', 'toolbar=no, status=no,scrollbars=0,resizable=0,menubar＝0,location=0,width=700,height=500');
			};
			document.getElementById('J_lightIn').onclick = function() {
				WKIT.init({
					container: document.getElementById('J_lightDemoWrap'),
					uid: 'admin',
					appkey: '25028535',
					credential: '123456',
					touid: 'test',
					theme: 'orange',
					pluginUrl: 'http://localhost:8070/view/138',
					customUrl: 'kit.html',
					logo: 'http://img.alicdn.com/tps/i3/TB12LD9IFXXXXb3XpXXSyFWJXXX-82-82.png',
					avatar: "imgs/1.png",
					toAvatar: "imgs/1.png"
				});

			}

			OpenIm.prototype.imLogin = function() {
				sdk.Base.login({
					uid: 'admin',
					appkey: '25028535',
					credential: '123456',
					timeout: 5000, //登录超时时间
					success: function(data) {
						console.log('login success', data);
						//  openIm.imGetRecentContact();

						sdk.Event.on('MSG_RECEIVED', function(data) {
							console.log(data);
							var content = data.data.msgs[0].msg;
							alert(content);

						});
						sdk.Base.startListenAllMsg();
					},
					error: function(error) {
						alert("消息获取失败,请刷新重试");
					}
				});
			}

			var openIm = null;

			function OpenIm() {}
			var sdk = new WSDK();

			$(function() {
				openIm = new OpenIm();
				openIm.imLogin();
				//每10妙更新未读消息
			    window.setInterval(function(){
			      openIm.getUsersUnreadMsgCount();
			    }, 10000);

			});
		</script>
	</body>

</html>